package com.hucii.app.activity;

import com.hucii.app.R;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;

/**
 * 统计表格
 * @author hongyun.fang
 *
 */
public class OrderStatisticalTableActivity extends BaseActivity {

	public final static String[] arr = { "10", "20", "50" };

	Spinner sp_all;
	Button btn_style;
	Button btn_brand;
	Button btn_type;

	ListView lv_list;

	MyAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setView(R.layout.order_statistical_table);

		initData();
		initView();
		registerListener();
		display();
	}

	private void initData() {

	}

	private void initView() {

		//
		sp_all = (Spinner) findViewById(R.id.sp_all);
		btn_style = (Button) findViewById(R.id.btn_style);
		btn_brand = (Button) findViewById(R.id.btn_brand);
		btn_type = (Button) findViewById(R.id.btn_type);

		lv_list = (ListView) findViewById(R.id.lv_list);

	}

	private void registerListener() {

	}

	private void display() {
		ArrayAdapter spPriceTypeAdapter = ArrayAdapter.createFromResource(this, R.array.top_num, android.R.layout.simple_spinner_item);
		spPriceTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		sp_all.setAdapter(spPriceTypeAdapter);

		adapter = new MyAdapter();
		lv_list.setAdapter(adapter);

	}

	class MyAdapter extends BaseAdapter {

		@Override
		public int getCount() {
			return 15;
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getView(int arg0, View view, ViewGroup arg2) {

			view = LayoutInflater.from(mContext).inflate(R.layout.order_statistical_table_item, null);
			TextView tv = new TextView(mContext);
			tv.setBackgroundColor(getResources().getColor(R.color.blue));
			LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll_parent);
			ll.addView(tv, new LinearLayout.LayoutParams((int)(40 * arg0 + 100), LayoutParams.FILL_PARENT));

			return view;
		}

	}

}
